﻿using System;

namespace Domain.Common
{
	public abstract class Entity
	{
		public Guid ID { get; set; }

		public bool Equals(Entity other)
		{
			if (ReferenceEquals(null, other))
				return false;

			if (ReferenceEquals(this, other))
				return true;

			return other.ID.Equals(ID);
		}

		public override bool Equals(object other) { return Equals(other as Entity); }

		public override int GetHashCode() { return ID.GetHashCode(); }

		public static bool operator ==(Entity left, Entity right)
		{
			if (ReferenceEquals(left, null))
				return ReferenceEquals(right, null);
			else
				return left.Equals(right);
		}

		public static bool operator !=(Entity left, Entity right) { return !(left == right); }
	}

	public abstract class AggregateRoot : Entity
	{}
}